// 获取热映电影信息
$(function() {
	$.ajax({
		method:"get",
		url: "https://douban.uieee.com/v2/movie/in_theaters",
		data:{
			start:"0",
			count:"6",
			city:""
		},
		dataType: "json",
		success: function(r) {
			r.subjects.forEach((e) => movie(e));
		}
	});
})

function movie(e) {
	// 提取电影类型信息
	let movieInfo = "";
	e.genres.forEach((genres)=> {
		movieInfo += '<span class="badge badge-info">'+genres+'</span> ';
	});
	// 电影图文信息
	let info =
			`<div class="col-md-4" style="margin-top:20px">
				<div class="card">
					<a href="${e.alt}"><img class="card-img-top" src="${e.images.small}" alt="Card image cap"></a>
					<div class="card-body">
						<h5 class="card-title"><span class="badge badge-danger">${e.rating.average}</span> ${e.title}</h5>
						<p class="card-text">${movieInfo}<span style="float:right">上映时间：${e.mainland_pubdate}</span></p>
					</div>
				</div>
			</div>`;
	// 展示到页面
	$(".row").append(info);

}
